<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript">
    var cardNo="";
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }

        function change(type,id,charge,payWay){
            if(charge==null || charge==""){
                 charge=0;
            }
            if(type == 0){
                var  message="确认退号,确认后请退还病人"+charge+"元";
                if(3==payWay){
                    cardNo = readOneCard();
                    if (!cardNo) {
                        toastr.error("读卡失败");
                        return false;
                    }else{
                        //一卡通退费
                        message="确认退号,"+charge+"元会退回到卡号:"+cardNo+"中";
                    }
                }
                confirmExtend(message,function(){delLoad('mainCenterDiv','${ctx}/oper/clinicMaster/backClinicForReg?id='+id+'&type='+payWay+'&charge='+charge+'&cardNo='+cardNo,'${ctx}/oper/clinicMaster/searchClinicRegInfo')});
            } else if(type == 1){
                toastr.warning("此号已经就诊不能退号");
            } else if(type == 2){
                toastr.warning("此号已经退号不能再次退号");
            }
        }
        function clinicPrint(id){
            printPdf('${ctx}/oper/patMasterIndex/printRegisit', 'id=' + id);
        }

</script>
    <div class="content-wrap">
        <div class="wrapper" style="bottom: 50px;">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="#"   onclick="loadDiv('mainCenterDiv','${ctx}/oper/clinicMaster/searchClinicRegInfo')">退号管理列表</a>
                </li>
            </ul>
            <section class="panel panel-default">
                <div class="panel-body">
                    <div class="table-responsive no-border">
                        <div class="datatable-top">
                            <div class="pull-left">
                            	<form:form id="searchForm" modelAttribute="clinicMaster"  onsubmit="return loadDivForm('mainCenterDiv','searchForm','${ctx}/oper/clinicMaster/searchClinicRegInfo');" method="post" class="form-inline">
                                    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                                    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                                    <label>就诊日期 ：</label>
                                    <input type="text" name="visitDate" value="<fmt:formatDate value="${clinicMaster.visitDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" class="form-control Wdate">
                                    &nbsp;&nbsp;&nbsp;
                                    <label>就诊序号 ：</label>
                                    <form:input path="visitNo" htmlEscape="false" maxlength="50" class="form-control" /> &nbsp;&nbsp;&nbsp;
                                    <label>挂号状态 ：</label>
                                    <form:select  path="clinicType" class="form-control" >
                                        <form:option value="">--请选择--</form:option>
                                        <form:option value="0">未就诊</form:option>
                                        <form:option value="1">已就诊</form:option>
                                        <form:option value="2">已退号</form:option>
                                    </form:select>
                                     &nbsp;&nbsp;&nbsp;
                                    <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
                                </form:form>
                            </div>
                        </div>
                        <table id="contentTable" class="table table-bordered mg-t datatable">
                            <thead>
                                <tr>
                                    <th>号别</th>
                                    <th>就诊日期</th>
                                    <th>门诊号</th>
                                    <th>姓名</th>
                                    <th>挂号状态</th>
                                    <th>实收费用</th>
                                    <th>支付方式</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${page.list}" var="clinicMaster">
                                <tr>
                                        <td> ${clinicMaster.clinicForRegist.clinicLabel}</td>
                                        <td> <fmt:formatDate value="${clinicMaster.visitDate}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                                        <td> ${clinicMaster.clinicNo}</td>
                                        <td> ${clinicMaster.name}</td>
                                        <td>
                                            <c:if test="${clinicMaster.clinicType == 0}">未就诊</c:if>
                                            <c:if test="${clinicMaster.clinicType == 1}">已就诊</c:if>
                                            <c:if test="${clinicMaster.clinicType == 2}">已退号</c:if>
                                        </td>
                                        <td> ${clinicMaster.clinicChage}</td>
                                        <td> ${fns:getDictLabel(clinicMaster.type, 'PAY_WAY_DICT', '')}</td>
                                    <td>
                                        <c:if test="${clinicMaster.clinicType != 2 && clinicMaster.clinicType != 1}">
                                            <a href="#"  class="applyBt btn btn-danger btn-xs" onclick=change('${clinicMaster.clinicType}','${clinicMaster.id}','${clinicMaster.clinicChage}','${clinicMaster.type}')>退号</a>
                                        </c:if>
                                        <a href="#"  class="btn btn-success btn-xs" onclick=clinicPrint('${clinicMaster.id}') >打印</a>
                                    </td>
                                </tr>
                            </c:forEach>

                        </table>
                        <div class="pagination">${page}</div>
                    </div>
                </div>
            </section>
        </div>
    </div>